********************************************************************************
*Replication files Ziller/Helbling: Public Support for State Surveillance
*European Journal of Political Research
*08 Nov 2020
********************************************************************************

*Load data

use ZH_surveillance_data, clear


********************************************************************************
****************************ANALYSIS********************************************
********************************************************************************

///Main effects

**Standardization DVs

reg agree trust_gov   i.policy i.datasec i.terror   sec if Land==2, beta //UK
foreach var of varlist trust_gov agree   {
egen std`var'=std(`var')  if e(sample)
}

reg stdagree  i.policy i.datasec i.terror , robust
eststo eagree_UK

reg stdtrust_gov  i.policy i.datasec i.terror, robust 
eststo etrust_gov_UK

drop std*
reg agree trust_gov   i.policy i.datasec i.terror  sec if Land==3, beta //FR
foreach var of varlist trust_gov agree  {
egen std`var'=std(`var')  if e(sample)
}

reg stdagree  i.policy i.datasec i.terror , robust
eststo eagree_FR

reg stdtrust_gov  i.policy i.datasec i.terror, robust 
eststo etrust_gov_FR


drop std*
reg agree trust_gov   i.policy i.datasec i.terror  sec if Land==4, beta //ES
foreach var of varlist trust_gov agree  {
egen std`var'=std(`var')  if e(sample)
}

reg stdagree  i.policy i.datasec i.terror , robust
eststo eagree_ES

reg stdtrust_gov  i.policy i.datasec i.terror, robust 
eststo etrust_gov_ES

drop std*
reg agree trust_gov   i.policy i.datasec i.terror  sec if Land==1, beta //DE
foreach var of varlist trust_gov agree  {
egen std`var'=std(`var')  if e(sample)
}

reg stdagree  i.policy i.datasec i.terror , robust
eststo eagree_DE

reg stdtrust_gov  i.policy i.datasec i.terror, robust 
eststo etrust_gov_DE


//Descriptives 

bys Land: tab1 agree trust_gov



**Figure 1 & 2: Effects of policy specifications on political support / political trust

ssc install asdoc, replace
ssc install coefplot, replace
ssc install grstyle, replace
set scheme s2color
. grstyle init
. grstyle color background white
. grstyle color major_grid dimgray
. grstyle linewidth major_grid thin
. grstyle yesno draw_major_hgrid yes
. grstyle yesno grid_draw_min yes
. grstyle yesno grid_draw_max yes
. grstyle anglestyle vertical_tick horizontal
. grstyle symbolsize p large
. grstyle color p1markline navy%0
. grstyle color p1markfill navy%70
. grstyle color p2markline maroon%0
. grstyle color p2markfill maroon%70
. grstyle color p3markline forest_green%0
. grstyle color p3markfill forest_green%70
. grstyle color p4markline dkorange%0
. grstyle color p4markfill dkorange%70
. grstyle color p5markline teal%0
. grstyle color p5markfill teal%70
. grstyle clockdir legend_position 4
. grstyle numstyle legend_cols 1
. grstyle linestyle legend none



	 
. grstyle symbolsize p small	 
coefplot  (eagree_DE , label("Germany")) (eagree_ES , label("Spain"))  (eagree_FR , label("France"))  (eagree_UK , label("United Kingdom")) ///
, baselevels coeflabels(0.policy="Not mentioned (baseline)"  1.policy="Dragnet scope" 2.policy="Targeted scope" ///
0.datasec="Not mentioned (baseline)" 1.datasec="Data security debated" 2.datasec="Data not secure"  ///
0.terror="Not mentioned (baseline)" 1.terror="No. of terror victims salient")  ///
headings(0.policy="{bf:Policy scope}" 0.datasec="{bf:Data security}" 0.terror="{bf:Security threat}") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) ysize(7) legend(position(7) row(1) size(small))

coefplot  (etrust_gov_DE , label("Germany")) (etrust_gov_ES , label("Spain"))  (etrust_gov_FR , label("France"))  (etrust_gov_UK , label("United Kingdom")) ///
, baselevels coeflabels(0.policy="Not mentioned (baseline)"  1.policy="Dragnet scope" 2.policy="Targeted scope" ///
0.datasec="Not mentioned (baseline)" 1.datasec="Data security debated" 2.datasec="Data not secure"  ///
0.terror="Not mentioned (baseline)" 1.terror="No. of terror victims salient")  ///
headings(0.policy="{bf:Policy scope}" 0.datasec="{bf:Data security}" 0.terror="{bf:Security threat}") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) ysize(7) legend(position(7) row(1) size(small))	 
	 




**FIGURE 3: Interaction Effects

//Germany only 
preserve
drop std*
reg agree trust_gov   i.policy i.datasec i.terror sec if Land==1 , beta 
foreach var of varlist trust_gov agree   {
egen std`var'=std(`var')  if e(sample)
}
 

reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin1: margins, dydx(policy) subpop(if terror==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin2: margins, dydx(policy) subpop(if terror==1) post

coefplot  margin1 margin2 , baselevels coeflabels(0.policy="Not mentioned (baseline)" 1.policy="Dragnet scope" 2.policy="Targeted scope") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) legend(  pos(12) size( vsmall)  row(1) label(2 "No security threat") label(4 "Security threat"))
gr save cplot3, replace

reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin1: margins, dydx(policy) subpop(if datasec==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin2: margins, dydx(policy) subpop(if datasec==2) post

coefplot  margin1 margin2 , baselevels coeflabels(0.policy="Not mentioned (baseline)" 1.policy="Dragnet scope" 2.policy="Targeted scope") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) legend(  pos(12) size( vsmall)  row(1)  label(2 "No salience data securtiy") label(4 "Data not secure"))
gr save cplot4, replace


reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin1: margins, dydx(policy) subpop(if sec==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin2: margins, dydx(policy) subpop(if sec==1) post

coefplot  margin1 margin2 , baselevels coeflabels(0.policy="Not mentioned (baseline)" 1.policy="Dragnet scope" 2.policy="Targeted scope") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) legend(  pos(12) size( vsmall)  row(1)  label(2 "Low need for security") label(4 "High need for security"))
gr save cplot5, replace


reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin1: margins, dydx(policy) subpop(if sec==0 & terror==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin2: margins, dydx(policy) subpop(if sec==0 & terror==1) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin3: margins, dydx(policy) subpop(if sec==1 & terror==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin4: margins, dydx(policy) subpop(if sec==1 & terror==1) post

coefplot  margin1 margin2 margin3 margin4 , baselevels coeflabels(0.policy="Not mentioned (baseline)" 1.policy="Dragnet scope" 2.policy="Targeted scope") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) legend(  pos(12) size( vsmall)  row(2)  label(2 "Low need sec. & no threat"  ) label(4 "Low need sec. & salient threat") ///
	  label(6 "High need sec. & no threat") label(8 "High need sec. & salient threat"))
gr save cplot6, replace


graph combine   "cplot3.gph" "cplot4.gph"    "cplot5.gph" "cplot6.gph",  cols(2)  graphregion(margin(zero))
restore


//All countries
preserve
drop std*
reg agree trust_gov   i.policy i.datasec i.terror sec  , beta  
foreach var of varlist trust_gov agree   {
egen std`var'=std(`var')  if e(sample)
}
 

reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin1: margins, dydx(policy) subpop(if terror==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin2: margins, dydx(policy) subpop(if terror==1) post

coefplot  margin1 margin2 , baselevels coeflabels(0.policy="Not mentioned (baseline)" 1.policy="Dragnet scope" 2.policy="Targeted scope") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) legend(  pos(12) size( vsmall)  row(1) label(2 "No security threat") label(4 "Security threat"))
gr save cplot3, replace

reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin1: margins, dydx(policy) subpop(if datasec==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin2: margins, dydx(policy) subpop(if datasec==2) post

coefplot  margin1 margin2 , baselevels coeflabels(0.policy="Not mentioned (baseline)" 1.policy="Dragnet scope" 2.policy="Targeted scope") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) legend(  pos(12) size( vsmall)  row(1)  label(2 "No salience data securtiy") label(4 "Data not secure"))
gr save cplot4, replace


reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin1: margins, dydx(policy) subpop(if sec==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin2: margins, dydx(policy) subpop(if sec==1) post

coefplot  margin1 margin2 , baselevels coeflabels(0.policy="Not mentioned (baseline)" 1.policy="Dragnet scope" 2.policy="Targeted scope") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) legend(  pos(12) size( vsmall)  row(1)  label(2 "Low need for security") label(4 "High need for security"))
gr save cplot5, replace


reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin1: margins, dydx(policy) subpop(if sec==0 & terror==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin2: margins, dydx(policy) subpop(if sec==0 & terror==1) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin3: margins, dydx(policy) subpop(if sec==1 & terror==0) post
reg stdagree  i.policy##i.terror##i.datasec##i.sec 
eststo margin4: margins, dydx(policy) subpop(if sec==1 & terror==1) post

coefplot  margin1 margin2 margin3 margin4 , baselevels coeflabels(0.policy="Not mentioned (baseline)" 1.policy="Dragnet scope" 2.policy="Targeted scope") ///
  ciopts(lwidth(*0.9)  ) levels(95)  grid(none) drop(_cons) xline(0) xtitle("Change in outcome (standard deviations)") ///
     mlabposition(12) byopts(row(1))  xscale(range(-0.6(0.2)0.6)) xlabel(-0.6(0.2)0.6) legend(  pos(12) size( vsmall)  row(2)  label(2 "Low need sec. & no threat"  ) label(4 "Low need sec. & salient threat") ///
	  label(6 "High need sec. & no threat") label(8 "High need sec. & salient threat"))
gr save cplot6, replace


graph combine   "cplot3.gph" "cplot4.gph"  "cplot5.gph" "cplot6.gph",  cols(2)  graphregion(margin(zero))
restore






	 
**Regression tables online appendix (A.9-A.12)
///Main effects
preserve
keep if Land==1
**Standardization DVs
drop std*
reg agree trust_gov   i.policy i.datasec i.terror   sec , beta //DE
foreach var of varlist trust_gov agree  {
egen std`var'=std(`var')  if e(sample)
}

asdoc reg stdagree  i.policy i.datasec i.terror , robust nest cnames(Main) save(DE.rtf) replace
asdoc reg stdagree  i.policy i.datasec i.terror sex age  sch2 sch3 sch1 haus inc i.rural , robust  nest cnames(wControl) append save(DE.rtf)

asdoc reg stdtrust_gov  i.policy i.datasec i.terror, robust append nest cnames(Main) save(DE.rtf)  
asdoc reg stdtrust_gov  i.policy i.datasec i.terror sex age   sch2 sch3 sch1  haus inc i.rural, robust  nest cnames(wControl) append save(DE.rtf)
restore

preserve
keep if Land==4
**Standardization DVs
drop std*
reg agree trust_gov   i.policy i.datasec i.terror   sec , beta //ES
foreach var of varlist trust_gov agree  {
egen std`var'=std(`var')  if e(sample)
}

asdoc reg stdagree  i.policy i.datasec i.terror , robust nest cnames(Main) save(ES.rtf) replace
asdoc reg stdagree  i.policy i.datasec i.terror sex age  sch2 sch3 sch1 haus inc i.rural , robust  nest cnames(wControl) append save(ES.rtf)

asdoc reg stdtrust_gov  i.policy i.datasec i.terror, robust append nest cnames(Main) save(ES.rtf)  
asdoc reg stdtrust_gov  i.policy i.datasec i.terror sex age   sch2 sch3 sch1  haus inc i.rural, robust  nest cnames(wControl) append save(ES.rtf)
restore

preserve
keep if Land==3
**Standardization DVs
drop std*
reg agree trust_gov   i.policy i.datasec i.terror   sec , beta //FR
foreach var of varlist trust_gov agree  {
egen std`var'=std(`var')  if e(sample)
}

asdoc reg stdagree  i.policy i.datasec i.terror , robust nest cnames(Main) save(FR.rtf) replace
asdoc reg stdagree  i.policy i.datasec i.terror sex age  sch2 sch3 sch1 haus inc i.rural , robust  nest cnames(wControl) append save(FR.rtf) format(%9.3f)

asdoc reg stdtrust_gov  i.policy i.datasec i.terror, robust append nest cnames(Main) save(FR.rtf)  
asdoc reg stdtrust_gov  i.policy i.datasec i.terror sex age   sch2 sch3 sch1  haus inc i.rural, robust  nest cnames(wControl) append save(FR.rtf)
restore

preserve
keep if Land==2
**Standardization DVs
drop std*
reg agree trust_gov   i.policy i.datasec i.terror   sec , beta //UK
foreach var of varlist trust_gov agree  {
egen std`var'=std(`var')  if e(sample)
}

asdoc reg stdagree  i.policy i.datasec i.terror , robust nest cnames(Main) save(UK.rtf) replace
asdoc reg stdagree  i.policy i.datasec i.terror sex age  sch2 sch3 sch1 haus inc i.rural , robust  nest cnames(wControl) append save(UK.rtf)

asdoc reg stdtrust_gov  i.policy i.datasec i.terror, robust append nest cnames(Main) save(UKtrust.rtf)  
asdoc reg stdtrust_gov  i.policy i.datasec i.terror sex age   sch2 sch3 sch1  haus inc i.rural, robust  nest cnames(wControl) append save(UK.rtf)
restore



